class Solution {
public:
    int strStr(string haystack, string needle) {
        if(needle==""){return 0;}
        if(needle.length()>haystack.length()){return -1;}
        if(needle.length()==haystack.length()){
            if(needle==haystack){return 0;}
            else{return -1;}
        }
        if(haystack==""){return -1;}
        int n=needle.length();
        for(int i=0;i<haystack.length()-n+1;i++){
            cout<<haystack.substr(i,n)<<" ";
            if(haystack.substr(i,n)==needle){return i;}
        }
        return -1;
    }
};